package device

import (
	"encoding/json"
	"gitee.com/zhanghuamingmyself/api"
	"gitee.com/zhanghuamingmyself/util"
)

var deviceParamBasePath = "iot/api/v1/v1/device/param/"

type IotDeviceParam struct {
	api.BaseDTO
	Port      string      `json:"port"`
	KeyName   string      `json:"keyName"`
	Unit      string      `json:"unit"`
	Value     interface{} `json:"value"`
	ValueDate int32       `json:"valueDate"`
}

type IotDeviceParamListReq struct {
	DeviceCore string `json:"deviceCore"`
	Port       string `json:"port"`
	Hidden     *bool   `json:"hidden"`
}

func ListDeviceParam(req IotDeviceParamListReq) ([]IotDeviceParam, error) {
	var deviceParamList []IotDeviceParam
	bytes, err := util.PostJson(deviceParamBasePath+"list", req)
	if err != nil {
		return deviceParamList, err
	}
	json.Unmarshal(bytes, &deviceParamList)
	return deviceParamList, nil
}
